package org.hackystat.installer.gears.view;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.hackystat.installer.gears.model.DownloadManager;


/**
 * Class:  CommandLineInterface
 * Description:  Rudimentary entry point into the system.
 * @author Josh
 *
 */
public class CommandLineInterface {

	private String configSetting;
	
	private String sensorBaseFile;
	
	public CommandLineInterface() {
		initGUI();
	}
	
	private void initGUI() {
		System.out.println("Choose a configuration:");
		System.out.println("");
		System.out.println("  1.  SensorBase");
		System.out.println("  2.  Sensors");
		System.out.println("  3.  Verify Prerequisites");
		System.out.println("  4.  Exit");
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			this.configSetting = br.readLine();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		if (this.configSetting.equals("1")) {
			sensorBaseConfiguration();
		}
		else if(this.configSetting.equals("2")) {
			sensorsConfiguration();
		}
		else if(this.configSetting.equals("3")) {
			checkPreqs();
		}
		else if(this.configSetting.equals("4")) {
			System.exit(0);
		}
		else {
			initGUI();
		}
//		initGUI();
	}
	
	private void sensorBaseConfiguration() {
		System.out.println("Downloading SensorBase ... ");
		DownloadManager d = new DownloadManager();
		d.getSensorBaseZipFile();
		d.unzipSensorBase();
	}
	
	private void sensorsConfiguration() {
		System.out.println("Downloading sensors package ... ");
		DownloadManager d = new DownloadManager();
	}
	
	private void checkPreqs() {
		DownloadManager d = new DownloadManager();
		d.RegisterEnvVariables();
	}
}
